/*menu*/
function corbeille() {
	$('#content').load('home/corbeille', function(){
		initTreemap('infovis',IsCorbeille,getData());
		policeTask();
		comptcorbeille(getData());
	});
}

$(function(){
	routes['/corbeille']=corbeille;			
});

function comptcorbeille(allTasks){
	var compteur=0;
	for (var i = 0; i < allTasks.length; i++) {
		if(allTasks[i].corbeille==1){
			compteur=compteur+1;
		}
	}
	$('.cptTasks').text(compteur + " tâches");
}

function delTasks(id) {
    var allTasks = getData();
    var i = 0;
    while (id != allTasks[i].id) {
        i = i + 1;
    }
    var laTacheASupprimer = { "id": allTasks[i].id, "objet": allTasks[i].objet, "priorite": allTasks[i].priorite, "date": allTasks[i].date, "description": allTasks[i].description, "lieu": allTasks[i].lieu, "couleur": allTasks[i].couleur, "corbeille": 1 };

    //allTasks.splice(i, 1, { "id": allTasks[i].id, "objet": allTasks[i].objet, "priorite": allTasks[i].priorite, "date": allTasks[i].date, "description": allTasks[i].description, "lieu": allTasks[i].lieu, "couleur": allTasks[i].couleur, "corbeille": 1 });

    saveDelete(laTacheASupprimer);
    accueil();
}

function saveDelete(laTacheASupprimer) {
        
        var json = JSON.stringify(laTacheASupprimer);

        $.ajax({
            url: 'home/corbeille',
            type: 'POST',
            dataType: 'json',
            data: json,
            contentType: 'application/json; charset=utf-8',
            success: function () {
                loadData(function () {
                    accueil();
                    //location.href = "/#/accueil";
                });
            }
        });
};